package com.lianzheng.dao.impl;

import java.util.List;
import java.util.Map;
import java.util.HashMap;

import com.lianzheng.dao.TbDocArticleattachDAO;
import com.lianzheng.model.TbDocArticleattach;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.orm.ObjectRetrievalFailureException;
import org.springframework.stereotype.Repository;


/**
 * This class interacts with Spring's IbatisTemplate to save/delete
 * <p>
 * <a href="TbDocArticleattach.DAOimpl.java.html"><i>View Source</i></a>
 * </p>
 *
 * @author <a href="mailto:heymanchen@gmail.com">haihua chen</a>
*/
@Repository
public class TbDocArticleattachDAOimpl extends SqlMapClientDaoSupport implements TbDocArticleattachDAO {

    /**
     * @see com.lianzheng.dao.TbDocArticleattachDAO#getTbDocArticleattach($keytype)
     */

    public TbDocArticleattach getTbDocArticleattach(String attachid){
        return (TbDocArticleattach)getSqlMapClientTemplate().queryForObject("getTbDocArticleattach", attachid);
    }

    public TbDocArticleattach getTbDocArticleattachFull(String attachid){
        return (TbDocArticleattach)getSqlMapClientTemplate().queryForObject("getTbDocArticleattachFull", attachid);
    }

    public void addTbDocArticleattach(final TbDocArticleattach tbDocArticleattach) {
        getSqlMapClientTemplate().update("addTbDocArticleattach", tbDocArticleattach);
    }

    public void updateTbDocArticleattach(final TbDocArticleattach tbDocArticleattach) {
    getSqlMapClientTemplate().update("updateTbDocArticleattach", tbDocArticleattach);
    }

    public void removeTbDocArticleattach(String attachid){
        getSqlMapClientTemplate().update("removeTbDocArticleattach", attachid);
    }

    public List getTbDocArticleattachs() {
        return getSqlMapClientTemplate().queryForList("getTbDocArticleattachs",null);
    }

    public List getTbDocArticleattachByAnd(final TbDocArticleattach tbDocArticleattach,String order_by){
        Map map = new HashMap();
        map.put(FIND_BY_AND, "True");
        if (order_by != null)
            map.put(ORDER_BY,order_by);
        tbDocArticleattach.setMagic(map);
        return getSqlMapClientTemplate().queryForList("getTbDocArticleattachByMap", tbDocArticleattach);
    }

    public List getTbDocArticleattachByOr(final TbDocArticleattach tbDocArticleattach,String order_by){
        Map map = new HashMap();
        map.put(FIND_BY_OR, "True");
        if (order_by != null)
            map.put(ORDER_BY,order_by);
        tbDocArticleattach.setMagic(map);
        return getSqlMapClientTemplate().queryForList("getTbDocArticleattachByMap", tbDocArticleattach);
    }
    
    public List getTbDocArticleattachByLike(final TbDocArticleattach tbDocArticleattach,String order_by){
        Map map = new HashMap();
        map.put(FIND_BY_LIKE, "True");
        if (order_by != null)
            map.put(ORDER_BY,order_by);
        tbDocArticleattach.setMagic(map);
        return getSqlMapClientTemplate().queryForList("getTbDocArticleattachByMap", tbDocArticleattach);
    }
}